<template>
    <div>
         <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="page"
        :page-sizes="[5, 10, 20, 50,100]"
        :page-size="size"
         layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        :url="url">
        </el-pagination>
    </div>
</template>

<script>
import { getTableData } from '@/utils/table';
export default{
    props:{
        "total":Number,
        "url":String
    },
    data(){
        return {
            page:1,//当前页数(子组件有就好，父组件不用了)
            size:10,//每页条数

        }
    },
    created(){
        getTableData(this.$parent,'/works',{size:this.size,page:this.page},['completed'])
    },
    methods:{
        //更改页面大小
        handleSizeChange(val) {
       this.size=val  //每页显示信息条数为val
       this.page=1 //页码数重置为1
        getTableData(this.$parent,'/works',{size:this.size,page:this.page},['completed'])//重新获取表格数据
      },
      //更改页码数
      handleCurrentChange(val) {
       this.page=val
        getTableData(this.$parent,'/works',{size:this.size,page:this.page},['completed'])////重新获取表格数据
      },
    }
}
</script>

<style lang="scss"></style>